<template>
	<el-main class="nopadding">
		<el-card shadow="never" header="CRM人员权限设置">
			<el-form-item label="销售经理" prop="manager">
				<select-user-dialog v-model:accountId="form.manager" :mode="true"/>
			</el-form-item>
			<el-form-item label="客户分配" prop="sender">
				<select-user-dialog v-model:accountId="form.sender" :mode="true"/>
			</el-form-item>
			<el-form-item label="业务员" prop="sale">
				<select-user-dialog v-model:accountId="form.salesman" :mode="true"/>
			</el-form-item>
			<div style="text-align: center;">
				<el-button type="primary" :loading="isSaveing" @click="submit()">保 存</el-button>
			</div>
		</el-card>
	</el-main>
</template>

<script>
import selectUserDialog from "@/views/module/selectUserDialog";

export default {
	name: 'Crm Role Manage',
	components: {
		selectUserDialog,
	},
	data() {
		return {
			isSaveing: false,
			form: {
				manager: "",
				sender: "",
				salesman: "",
			}
		}
	},
	mounted() {
		this.getCrmRoleInfo();
	},
	methods: {
		async submit() {
			var res = await this.$API.crm.crmRole.setCrmRole.post(this.form);
			this.isSaveing = false;
			if (res.code == 200) {
				this.$message.success("操作成功")
			} else {
				this.$alert(res.message, "提示", {type: 'error'})
			}
		},
		async getCrmRoleInfo() {
			var res = await this.$API.crm.crmRole.getCrmRole.get();
			if (res.code == 200) {
				if(res.data!=undefined)
				{
					this.form = res.data;
				}
			} else {
				this.$alert(res.message, "提示", {type: 'error'})
			}
		}
	}
}
</script>

<style>
</style>
